//
// Created by Administrator on 2022/7/7.
//
#include "Tree.cpp"
//删除以X值为根的子树
void dele(Tree root){
    if(root->leftChild) dele(root->leftChild);
    if(root->rightChild) dele(root->rightChild);
    root->data=-1;
}
void dele_part(Tree root,int x){
    if(root->data==x){
        dele(root);
    }
    else{
        if(root->leftChild){
            dele_part(root->leftChild,x);
        }
        if(root->rightChild){
            dele_part(root->rightChild,x);
        }
    }
}
void traverse(Tree root){
    if(root!=NULL){
        printf("%d",root->data);
        traverse(root->leftChild);
        traverse(root->rightChild);
    }
}
int main(){
    Tree tree = CreateTreeByFile("Day-615-1.txt");
    dele_part(tree,3);
    traverse(tree);
}